String.prototype.Trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
} 

//********************************************************************
    //处理 firefox innerText
   var lBrowser = {};
   lBrowser.agt = navigator.userAgent.toLowerCase();
   lBrowser.isW3C = document.getElementById ? true:false;
   lBrowser.isIE = ((lBrowser.agt.indexOf("msie") != -1) && (lBrowser.agt.indexOf("opera") == -1) && (lBrowser.agt.indexOf("omniweb") == -1));
   lBrowser.isNS6 = lBrowser.isW3C && (navigator.appName=="Netscape") ;
   lBrowser.isOpera = lBrowser.agt.indexOf("opera") != -1;
   lBrowser.isGecko = lBrowser.agt.indexOf("gecko") != -1;
   lBrowser.ieTrueBody =function ()
   {
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
   };
   //为Firefox下的DOM对象增加innerText属性
   if(lBrowser.isNS6){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__( "innerText",function(){return this.textContent;});
   HTMLElement.prototype.__defineSetter__( "innerText",function(sText){this.textContent=sText;});
   }
   //**************************************************************************************


function g(obj)
{return document.getElementById(obj);}


//获取字符长度
function getlength(sText)
{
   var svar=sText.Trim();
   sText=svar;
   
   var idex=0;
   var len=0;
   for(idx=0;idx<sText.length;idx++)
   {
      var cd=sText.charCodeAt(idx);
      if(cd<256)
      {
          len=len+1;
      }
      else
      {
          len=len+2;
      }
   }
   return len;
}


//检查是否有\`~'等字符
function checkSpecChar(s){
  for(var i=0;i<s.length;i++){
    var c=s.substring(i,i+1);
    if( (c=='\\') || (c=="'") || (c=="\"")){
      return false;
    }
  }
  return true;
}
//电话号码中只能有数字，*-()
function checkPhoneNum(s){
  if(IsNum(s)){
    return true;
  }
  for(var i=0;i<s.length;i++){
    var c=s.substring(i,i+1);
    if(IsNum(c)==true)
      continue;
    else{
      if((c=='*') || (c=='-') || (c=='(')||(c==')'))
        continue;
      else
        return false;
    }
  }
  return true;
}

//检查检查客户帐号输入是否正确
function checkCustNo(num){

	if(!IsNum(num)){
		return false;
	}

	if(num.length!=12){
		return false;
	}

	if(num.substring(0,2)!="04"){
		return false;
	}

	if(!checkPer(num)){
		return false;
	}
	return true;
}


//去除份数中的","
function releasedot(num){
	num=num.toString();
	 var returnnum="";
	 var i=0;
	 while(i<num.length){
         var c = num.substring(i,i+1);
         //alert(c);
         if(c!=",")
         {
         returnnum=returnnum+c;
         }
         i++;
	}
	return returnnum;
	
	}


function checkPer(num){
	var tempNum = 0;
	for(var i=0;i<num.length-1;i++){
		tempNum += parseFloat(num.substring(i,i+1))*(i+1);
	}
	tempNum = tempNum + "";
	if(tempNum.substring(tempNum.length-1)==num.substring(num.length-1)){
		return true;
	}else{
        	return false;
	}
}

//检查身份证输入是否正确
function checkID(num){
	if(!IsNum(num.substring(0,num.length-1))){
		return false;
	}

	if(num.length==15){
		if(!checkDate(num.substring(6,12))){
			return false;
		}
	}else if(num.length==18){
		if(!checkDate(num.substring(6,14))){
			return false;
		}
	}else{
		return false;
	}
	return true;
}


//判断num是否为格式yyyymmdd的日期
function checkDate(num){
  var year,month,day;
  if(num.length==6){
    year = 19 + num.substring(0,2);
    month = num.substring(2,4);
    day = num.substring(4,6);
  }else if(num.length==8){
    year =  num.substring(0,4);
    month = num.substring(4,6);
    day = num.substring(6,8);
  }

  if(!checkRange(year,month,day)){
    return false;
  }

  return true;
}

//判断年月日是否在范围之内
function checkRange(pYear,pMonth,pDay){
  days = new	Array(13);
  days[1] = 31;
  days[2] = 28;
  days[3] = 31;
  days[4] = 30;
  days[5] = 31;
  days[6] = 30;
  days[7] = 31;
  days[8] = 31;
  days[9] = 30;
  days[10] = 31;
  days[11] = 30;
  days[12] = 31;

      pYear = parseInt(pYear,10);
      pMonth = parseInt(pMonth,10);
      pDay = parseInt(pDay,10);

  if ((pYear%4==0&&pYear%100!=0) || (pYear%400==0))
    days[2] = 29;


  if (pYear<1900||pYear>3000)		return	false;
  if (pMonth<1||pMonth>12)		return	false;
  if (pDay>days[pMonth]||pDay<1)	return	false;

  var today  = new     Date();
      var tYear = today.getYear();
      if (tYear < 100)
          tYear = 1900 + tYear;
      tMonth = today.getMonth()+1;
      tToday = today.getDate();


  if(parseFloat(pYear)>parseFloat(tYear)){
    return false;
  }else if(parseFloat(pYear)==parseFloat(tYear)){
    if(parseFloat(pMonth)>parseFloat(tMonth)){
      return false;
    }else if(parseFloat(pMonth)==parseFloat(tMonth)){
      if(parseFloat(pDay)>parseFloat(tToday)){
        return false;
      }
    }
  }
  return	true;
}
//判断年月日是否在范围之内
function checkRange_notoday(pYear,pMonth,pDay){
  days = new	Array(13);
  days[1] = 31;
  days[2] = 28;
  days[3] = 31;
  days[4] = 30;
  days[5] = 31;
  days[6] = 30;
  days[7] = 31;
  days[8] = 31;
  days[9] = 30;
  days[10] = 31;
  days[11] = 30;
  days[12] = 31;

      pYear = parseInt(pYear,10);
      pMonth = parseInt(pMonth,10);
      pDay = parseInt(pDay,10);

  if ((pYear%4==0&&pYear%100!=0) || (pYear%400==0))
    days[2] = 29;


  if (pYear<1900||pYear>3000)		return	false;
  if (pMonth<1||pMonth>12)		return	false;
  if (pDay>days[pMonth]||pDay<1)	return	false;


  return	true;
}

//非空判定
	function isNull(obj){
		if ((obj==null)||(obj=="null")||(obj.length==0)) return true;
		else return false;
	}

//数字判定包括浮点数
      function IsNum(str){
          var j=0;
          var ch="";
          str=trim(str);
          if (str.length==0) return false;
          for (var i=0;i<str.length;i++){
              ch=str.charAt(i);
              if (ch=="."){
                  j++;
                  if (j>1){
                      return false;
                  }
              }else if ((parseInt(ch)+"")=="NaN"){
                  return false;
              }
          }
          return true;
      }
//数字判定包括浮点数
      function IsNum2PointNum(str){
          var j=0;
          var ch="";
          var pointnum=0;
          str=trim(str);
          if (str.length==0) return false;
          for (var i=0;i<str.length;i++){
              ch=str.charAt(i);
              if (ch=="."){
                  j++;
                  if (j>1){
                      return false;
                  }
              }else if ((parseInt(ch)+"")=="NaN"){
                  return false;
              }
              if(j>0)
              
                pointnum++;
              if(pointnum>3)
                return false;
          }
          return true;
      }
      
 //判定nav小数3位
      function IsNum3PointNum(str){
          var j=0;
          var ch="";
          var pointnum=0;
          str=trim(str);
          if (str.length==0) return false;
          for (var i=0;i<str.length;i++){
              ch=str.charAt(i);
              if (ch=="."){
                  j++;
                  if (j>1){
                      return false;
                  }
              }else if ((parseInt(ch)+"")=="NaN"){
                  return false;
              }
              if(j>0)
              
                pointnum++;
              if(pointnum>4)
                return false;
          }
          return true;
      }    
      
  
//整数判定
	function isInt(val){
		for (i=0;i<val.length;i++){
			p = val.charAt(i);
			if (p<'0'||p>'9'){
        if(i==0&&p=='-')
          continue;
        else
          return	false;
			}
		}
		return	true;
	}

//左去空
	 function ltrim(str){
		str=str+"";
		if (str.length==0){
			return str;
		}
		var i=0;
		while ((i<str.length)&&(str.substring(i,i+1)==" ")) i++;
		return str.substring(i,str.length);
	 }
//右去空
	 function rtrim(instr){
		instr=instr+"";
		var last_space;
		var ret;
		last_space = instr.length;
		while ((instr.charAt( last_space - 1 ) == " " )&&(last_space > 0)) {
		  last_space --;
		}
		if (last_space==0){
			return ""
		}else{
			return instr.substring( 0, last_space );
		}
	 }
//去空

       function trim(s){
           return   ltrim(rtrim(s));
       }

       //判断输入是否有'@'
       function isEmail(s){
         if(s.length<5)
           return false;
         if((s.charAt(0)=="@")||(s.charAt(0)=="."))
           return false;
         if((s.charAt(s.length-1)=="@")||(s.charAt(s.length-1)=="."))
           return false;
         var count=0;
         var hasdot=false;
         for(var i=0;i<s.length;i++){
           if(s.charAt(i)=="@")
             count++;
           else if(s.charAt(i)==".")
             hasdot=true;
         }
         if((count==1)&&(hasdot==true))
           return true;
         return false;
       }
       function chineselen(s){

         var esclen=escape(s).length;
         var len=s.length;

         var rtnlen;
         rtnlen=((esclen-len)/5)*2+(len-(esclen-len)/5);
         return rtnlen;
       }


     function changetradenm(finatype,bankno)
     {
     var fundaccountname="-";

     if((finatype=="1")&&(bankno=="014"))  {fundaccountname="民生银基通";}
      else if((finatype=="1")&&(bankno=="114"))  {fundaccountname="民生银基通";}
     	  else if((finatype=="1")&&(bankno=="015"))  {fundaccountname="兴业银基通";}
     		  else if((finatype=="1")&&(bankno=="009"))  {fundaccountname="浦发银基通";}
     			 else if((finatype=="1")&&(bankno=="007"))  {fundaccountname="招行直付通";}
     			 	 else if((finatype=="1")&&(bankno=="003"))  {fundaccountname="农行委托扣款";}
     			 	 	 else if((finatype=="5")&&(bankno=="003"))  {fundaccountname="农行网上直销";}
     			 	 	   else if((finatype=="2")&&(bankno=="015"))  {fundaccountname="银联通兴业";}
     			 	 	 	   else if((finatype=="1")&&(bankno=="005"))  {fundaccountname="建行E付通";}
     			 	 	 	  	 else if((finatype=="1")&&(bankno=="201"))  {fundaccountname="汇付天天盈";}
     			 	 	 	  	 	 else if((finatype=="1")&&(bankno=="002"))  {fundaccountname="工行银基通";}
     			 	 	 	  	 	 	 else if((finatype=="2")&&(bankno=="008"))  {fundaccountname="银联通中信";}
     			 	 	 	  	 	 	 	 else if((finatype=="2")&&(bankno=="374"))  {fundaccountname="银联通浙商";}
     			 	 	 	  	 	 	 	 	 else if((finatype=="2")&&(bankno=="402"))  {fundaccountname="银联通上农";}
	 	 	 	  	 	 								  else if((finatype=="2")&&(bankno=="343"))  {fundaccountname="银联通温商";}
	 	 	 	  	 	 								  	else if((finatype=="2")&&(bankno=="330"))  {fundaccountname="银联通南商";}
	 	 	 	  	 	 								  		else if((finatype=="2")&&(bankno=="333"))  {fundaccountname="银联通杭商";}
	 	 	 	  	 	 								  			 else if((finatype=="2")&&(bankno=="014"))  {fundaccountname="银联通民生";}
	 	 	 	  	 	 								  			 	 else if((finatype=="2")&&(bankno=="010"))  {fundaccountname="银联通光大";}
	 	 	 	  	 	 								  			 	 	 else if((finatype=="1")&&(bankno=="006"))  {fundaccountname="交行网上直销";}
     return fundaccountname;
     	
     }



    function getipnoto18(cardID)
   {
   
   var cardID17 = cardID.substring(0,6)+"19"+cardID.substring(6); 

   var N=0;
   var R = -1; 
   var T = '0';//储存最后一个数字 
   var j = 0; 
   var v = new Array(); 
   var vs = "10X98765432"; 
   
   v.push(2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4, 8, 5, 10, 9, 7); 
   for (var i = 16;i >= 0;i--) 
   {
   N+= parseInt(cardID17.substring(i, i + 1)) * v[j]; 
   
   j++; 
   } 

   R = N % 11; 
   T = vs.charAt(R); 

   cardID18 = cardID17 + T; 
   
   return(cardID18);
   
   }
   
    function getipnoto15(cardID)
   {
   
   var cardID15 = cardID.substring(0,6)+cardID.substring(8,17); 
     
   return(cardID15);
   
   }